﻿using System;

using SharpOSCAR.Base;

namespace SharpOSCAR.Snac.BUDDY
{
    /// <summary>
    /// This SNAC is optionally sent by the client to discover the client's and user's rights.
    /// </summary>
    /// <remarks>
    /// This SNAC is usually sent before the OSERVICE__CLIENT_ONLINE SNAC.
    /// </remarks>
    public class BUDDY__RIGHTS_QUERY : SNAC__Header
    {
        private TlvArray _Tlvs;

        /// <summary>
        /// Initializes the BUDDY__RIGHTS_QUERY SNAC
        /// </summary>
        /// <param name="requestId">SNAC request ID</param>
        public BUDDY__RIGHTS_QUERY(uint requestId)
            : this(requestId, (BUDDY__RIGHTS_QUERY_FLAGS.BART_SUPPORTED |
                               BUDDY__RIGHTS_QUERY_FLAGS.INITIAL_DEPARTS |
                               BUDDY__RIGHTS_QUERY_FLAGS.OFFLINE_BART_SUPPORTED |
                               BUDDY__RIGHTS_QUERY_FLAGS.REJECT_PENDING_BUDDIES))
        { }

        /// <summary>
        /// Initializes the BUDDY__RIGHTS_QUERY SNAC with the specified RIGHTS flags
        /// </summary>
        /// <param name="requestId">SNAC request ID</param>
        /// <param name="supportedFlags">Supported flags</param>
        public BUDDY__RIGHTS_QUERY(uint requestId, BUDDY__RIGHTS_QUERY_FLAGS supportedFlags)
            : base(3, 2, 0, requestId)
        {
            _Tlvs = new TlvArray();
            _Tlvs.AddTlv(new Tlv(6, new U16((ushort)supportedFlags)));
            SnacPayload = _Tlvs;
        }
    }
}
